/**
 * Created by Richard Radlherr.
 * Date: 16.06.2006 09:57
 */

using System;
using TagTool.Core;
using TagTool.GraphicTypes;

namespace TagTool.Nodes.Math
{
	public class Sin : BaseNode
	{
		private InputSlot slotA;
		private OutputSlot slotB;
  
		public Sin() : base()
		{
			Name = "Sinus";
			slotA = new InputSlot(this, "A", 0.0);
			slotB = new OutputSlot(this, "B", typeof(double));
			slotB.Value = 0.0;
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}
		
		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotB
		{
			get { return slotB; }
		}

		public override void Update(Object sender)
		{
			slotB.Value = System.Math.Sin((double)slotA.Value);
		}

	}
		
	public class Cos : BaseNode
	{
		private InputSlot slotA;
		private OutputSlot slotB;
  
		public Cos() : base()
		{
			Name = "Cosinus";
			slotA = new InputSlot(this, "A", 0.0);
			slotB = new OutputSlot(this, "B", typeof(double));
			slotB.Value = 0.0;
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}
		
		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotB
		{
			get { return slotB; }
		}

		public override void Update(Object sender)
		{
			slotB.Value = System.Math.Cos((double)slotA.Value);
		}

	}
	
	public class Exp : BaseNode
	{
		
		private InputSlot factor;
		private InputSlot slotA;
		private OutputSlot slotB;
  
		public Exp() : base()
		{
			Name = "Exp";
			factor = new InputSlot(this, "Factor", 1.0);
			factor.ParseCallback = ParseHelper.ParseDouble;
			
			slotA = new InputSlot(this, "A", 0.0);
			slotA.ParseCallback = ParseHelper.ParseDouble;
			
			slotB = new OutputSlot(this, "B", typeof(double));
			slotB.Value = 1.0;
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot Factor
		{
			get { return factor; }
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}
		
		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotB
		{
			get { return slotB; }
		}

		public override void Update(Object sender)
		{
			slotB.Value = (System.Math.Exp(-(double)slotA.Value) * (double)factor.Value );
		}

	}
	
	
	public class Log : BaseNode
	{
		
		private InputSlot factor;
		private InputSlot slotA;
		private OutputSlot slotB;
  
		public Log() : base()
		{
			Name = "Log";
			factor = new InputSlot(this, "Factor", 1.0);
			factor.ParseCallback = ParseHelper.ParseDouble;
			
			slotA = new InputSlot(this, "A", 0.0);
			slotA.ParseCallback = ParseHelper.ParseDouble;
			
			slotB = new OutputSlot(this, "B", typeof(double));
			slotB.Value = 1.0;
		}
		
		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot Factor
		{
			get { return factor; }
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}
		
		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotB
		{
			get { return slotB; }
		}

		public override void Update(Object sender)
		{
			slotB.Value = (System.Math.Log((double)slotA.Value) * (double)factor.Value );
		}

	}
}
